import 'dart:io';

import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/constant/image_constant.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/provider/user/login.dart';
import 'package:distribution_mall_flutter/utils/common_widget.dart';
import 'package:distribution_mall_flutter/utils/image_loader.dart';
import 'package:distribution_mall_flutter/widgets/horizontal_divider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class ThirdPartyLogin extends ConsumerWidget {
  const ThirdPartyLogin({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Column(
      children: [
        Row(
          children: [
            const EPHorizontalDivider(
              isExpand: true,
            ),
            Text(
              S.current.user_login_or,
              style: const TextStyle(
                  color: Color.fromRGBO(134, 141, 150, 1),
                  fontSize: FontConstant.f146,
                  letterSpacing: TextConstant.letterSpacing),
            ),
            const EPHorizontalDivider(isExpand: true),
          ],
        ),
        const SizedBox(
          height: 35.5,
        ),
        Column(
          children: [
            CommonBtnWidget.generalBtn(
              () {
                ref.read(loginProvider.notifier).googleSignIn(ref);
              },
              width: 331.3,
              height: 45.5,
              radius: 22.8,
              color: Colors.white,
              text: S.current.with_google,
              border: Border.all(width: 0.9, color: ColorConstant.grey221),
              textStyle: const TextStyle(
                  fontSize: FontConstant.f146,
                  color: Colors.black,
                  letterSpacing: TextConstant.letterSpacing),
              icon: ImageLoader.imageAsset(ImageLocalConstant.google,
                  width: 21.8, height: 21.8),
            ),
            const SizedBox(
              height: 21.8,
            ),
            if (!kIsWeb && Platform.isIOS)
              CommonBtnWidget.generalBtn(
                () {
                  ref.read(loginProvider.notifier).appleSignIn(ref);
                },
                width: 331.3,
                height: 45.5,
                radius: 22.8,
                color: Colors.white,
                text: S.current.with_apple,
                border: Border.all(width: 0.9, color: ColorConstant.grey221),
                textStyle: const TextStyle(
                    fontSize: FontConstant.f146,
                    color: Colors.black,
                    letterSpacing: TextConstant.letterSpacing),
                size: 35,
                icon: const Icon(
                  Icons.apple,
                ),
              )
          ],
        ),
      ],
    );
  }
}
